package com.ynunicom.dc.dingdingcontractapp.tasklistener;

import com.ynunicom.dc.dingdingcontractapp.utils.SpringHelper;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;

import javax.annotation.Resource;

/**
 * @author: jinye.Bai
 * @date: 2020/6/5 16:50
 */
public class DeptTaskStartListener implements TaskListener {
    private static final long serialVersionUID = -4478689846394894779L;

    @Override
    public void notify(DelegateTask delegateTask) {
        TaskService taskService = SpringHelper.getTaskService();
        String isDeptOk = (String) taskService.getVariables(delegateTask.getId()).get("isDeptOk");
        if (Boolean.parseBoolean(isDeptOk)){
            taskService.complete(delegateTask.getId());
        }
    }
}
